package com.ankifyh.lazeedrive;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.os.PowerManager;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private EditText inputBox;
    private PowerManager.WakeLock wakeLock;

    @SuppressLint("InvalidWakeLockTag")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //保持屏幕常亮
        PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
        wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "MyWakeLockTag");
        // Acquire the wake lock
        wakeLock.acquire(24*60*60*1000L /*24小时*/);

        // 设置布局为仅包含一个全屏输入框
        setContentView(R.layout.activity_main);

        // 初始化输入框
        inputBox = findViewById(R.id.input_box);

        // 设置提示文字
        //inputBox.setHint("这是一个基于\"时间拳击法\"和\"消除模糊理念\"设计的应用程序，在这里写下你下一步要做的事情，事情困难，那么下一步就是拆解事情");

        TextView instructionButton = findViewById(R.id.instructionButton);
        instructionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, InstructionActivity.class);
                startActivity(intent);
            }
        });

        ImageView imageView = findViewById(R.id.icon_launcher);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, TipActivity.class);
                startActivity(intent);
            }
        });
    }

    // 可选：添加方法处理输入框内容的变化，如保存用户输入、验证等
    /*@Override
    public void afterTextChanged(Editable s) {
        // TODO: 实现输入内容变化后的逻辑
    }*/

    // 可选：添加额外的视图交互逻辑，如点击按钮提交等
    /*@Override
    public void onClick(View view) {
        String userInput = inputBox.getText().toString().trim();
        // TODO: 处理用户提交的输入
    }*/

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (wakeLock != null && wakeLock.isHeld()) {
            wakeLock.release();
        }
    }
}